export default function (self, num) {
  return {
    extend: {
      legend: {
        orient: 'vertical',
        top: 160,
        left: 300,
        itemGap: 15,
        formatter: function (name) {
          return [
            `{title|${name}}`
          ].join('\n')
        },
        textStyle: {
          color: '#fff',
          rich: {
            title: {
              color: '#eee',
              padding: [17, 0]
            }
          }
        }
      },
      series: {
        bottom: 350,
        right: 150,
        label: {
          show: false,
          position: 'center'
        },
        emphasis: {
          label: {
            show: true,
            formatter: (item) => {
              if (self.pieDate.length < num) {
                self.pieDate.push({
                  color: item.color,
                  percent: item.percent,
                  value: item.value,
                  name: item.name
                })
              }
              let className1 = 'defaultColor'
              let className2 = 'defaultColorValue'
              switch (item.color) {
                // 绿色
                case '#00dc6a':
                  className1 = 'green'
                  className2 = 'greenValue'
                  break
                // 黄色
                case '#ffd200':
                  className1 = 'yellow'
                  className2 = 'yellowValue'
                  break
                // 红色
                case '#ff5454':
                  className1 = 'red'
                  className2 = 'redValue'
                  break
                default:
                  className1 = 'defaultColor'
                  className2 = 'defaultColorValue'
                  break
              }
              return [
                `{${className1}|${item.percent}%}`,
                `{${className2}|${item.data.name}占比}`
              ].join('\n')
            },
            rich: {
              red: {
                fontSize: 30,
                color: '#ff5454',
                padding: [10, 0, 10, 0]
              },
              yellow: {
                fontSize: 30,
                color: '#ffd200',
                padding: [10, 0, 10, 0]
              },
              green: {
                fontSize: 30,
                color: '#00dc6a',
                padding: [10, 0, 10, 0]
              },
              defaultColor: {
                fontSize: 30,
                color: '#fff',
                padding: [10, 0, 10, 0]
              },
              redValue: {
                fontSize: 16,
                color: '#ff5454'
              },
              yellowValue: {
                fontSize: 16,
                color: '#ffd200'
              },
              greenValue: {
                fontSize: 16,
                color: '#00dc6a'
              },
              defaultColorValue: {
                fontSize: 16,
                color: '#fff'
              }
            }
          }
        }
      }
    }
  }
}
